package com.unicampmaps;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class VenueData {
	private static final String TAG = VenueData.class.getSimpleName();
	static final int VERSION = 1;	
	
	public static final int T_RESTAURANT = 1;
	public static final int T_CLASSROOM = 2;
	public static final int T_SERVICES = 3;
	public static final int T_LIBRARY = 4;
	public static final int T_TRANSPORT = 5;
	public static final int T_OTHER = 6;
	
	public static final String TABLE = "venues";
	
	public static final String C_ID = "_id";
	public static final String C_FOURSQUARE_VENUE_ID = "foursquare_venue_id";
	public static final String C_TYPE = "type";
	public static final String C_NAME = "name";
	public static final String C_ABBR = "abbr";
	public static final String C_ADDRESS = "address";
	public static final String C_LATITUDE = "latitude";
	public static final String C_LONGITUDE = "longitude";
	public static final String C_PHONE_NUMBER = "phone_number";
	public static final String C_SITE = "site";
	public static final String C_IMAGE = "image";
	
	private static final String DATABASE_CREATE = 
			"CREATE TABLE if not exists " + TABLE + " (" + 
				C_ID + " INTEGER primary key, " +
				C_FOURSQUARE_VENUE_ID + " TEXT, " +
				C_TYPE + " INTEGER, " +
				C_NAME + " TEXT, " +
				C_ABBR + " TEXT, " +
				C_ADDRESS + " TEXT, " +
				C_LATITUDE + " REAL, " + 
				C_LONGITUDE + " REAL, " +
				C_PHONE_NUMBER + " TEXT, " +
				C_SITE + " TEXT, " +
				C_IMAGE + " TEXT)";
	
	
	public static void onCreate(SQLiteDatabase db) {
		Log.w(TAG, DATABASE_CREATE);
		System.out.println("ONCREATE Data");
		db.execSQL(DATABASE_CREATE);
	}

	public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
		+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE);
		onCreate(db);
	}
}
